package com.lgj.pay.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lgj.pay.service.UserService;
import com.lgj.pay.model.User;
import com.lgj.pay.mapper.UserMapper;
import com.lgj.rocketmq.annotation.RocketMqConsumer;
import com.lgj.rocketmq.annotation.RocketMqMessageListener;
import com.lgj.rocketmq.message.RocketMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author lgj18
* @description 针对表【user】的数据库操作Service实现
* @createDate 2023-09-06 22:46:18
*/
@Slf4j
@Service
@RocketMqConsumer(group = "transaction",instanceName = "payment",messageModel = MessageModel.CLUSTERING)
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @RocketMqMessageListener(topic = "payment-transaction")
    public void localMethod(RocketMessage transactionMessage) {
        String boyd = (String) transactionMessage.getBody();
        log.info("测试消息--------"+boyd);
        User  user = new User();
        user.setId(1);
        user.setPassword("987654");
        userMapper.updateById(user);
    }
}




